/**
 * 
 */
package SimulLois;

import org.apache.log4j.Logger;

import SimulLois.interfaces.Lois;

/**
 * @author Propriétaire
 * 
 */
public class Exponentielle implements Lois {
	
	public static Logger	LOG	= Logger.getLogger(Exponentielle.class);
	
	private Double	     lambda;
	
	public Exponentielle(Double lambda) {
		this.lambda = lambda;
	}
	
	public static Double randExponentielle(Double lambda) {
		
		LOG.info("Invocking Exponentielle generator");
		
		Double u = Math.random();
		return Math.log(1 - u) / (-lambda);
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see main.java.SimulLois.interfaces.Lois#gen()
	 */
	@Override
	public Double gen() {
		// TODO Auto-generated method stub
		return randExponentielle(lambda);
	}
	
	/**
	 * @return the lambda
	 */
	public Double getLambda() {
		return lambda;
	}
	
	/**
	 * @param lambda
	 *            the lambda to set
	 */
	public void setLambda(Double lambda) {
		this.lambda = lambda;
	}
	
}
